import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login',
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/Login.vue'),
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('../views/Dashboard.vue'),
      children: [
        {
          path: 'home',
          name: 'home',
          component: () => import('../views/Home.vue'),
        },
        {
          path: 'road-management',
          name: 'road-management',
          component: () => import('../views/RoadManagement.vue'),
        },
        {
          path: 'statistics',
          name: 'statistics',
          component: () => import('../views/Statistics.vue'),
        },
        {
          path: 'ServiceAreaManagement',
          name: 'ServiceAreaManagement',
          component: () => import('../views/ServiceAreaManagement.vue'),
        },
        {
          path: 'EntranceManagement',
          name: 'EntranceManagement',
          component: () => import('../views/EntranceManagement.vue'),
        },
        {
          path: 'UserAddAccident',
          name: 'UserAddAccident',
          component: () => import('../views/UserAddAccident.vue'),
        },
        {
          path: 'GoToServiceAndEntrance',
          name: 'GoToServiceAndEntrance',
          component: () => import('../views/GoToServiceAndEntrance.vue'),
        },
        {
          path: 'HandleAccident',
          name: 'HandleAccident',
          component: () => import('../views/HandleAccident.vue'),
        },
        {
          path: 'AddAccidentPoint',
          name: 'AddAccidentPoint',
          component: () => import('../views/AddAccidentPoint.vue'),
        },
        {
          path: 'highway-query',
          name: 'highway-query',
          component: () => import('../views/HighwayQuery.vue'),
        },
        // 默认重定向到首页
        {
          path: '',
          redirect: '/dashboard/home',
        },
      ],
    },
  ],
})

export default router
